From db4106c401983891199c900cb8f3736e14ccc307 Mon Sep 17 00:00:00 2001 From: robertl Date: Mon, 9 Dec 2002 06:00:26 +0000 Subject: [PATCH] Attempt to plaster over note->description grief when wpt is added. Add option to CSV to prefer shortname over description. --- gpsbabel/csv.c | 12 ++++++++++-- gpsbabel/waypt.c | 5 +++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/gpsbabel/csv.c b/gpsbabel/csv.c index b2141d9c3..3d6922fde 100644 --- a/gpsbabel/csv.c +++ b/gpsbabel/csv.c @@ -26,6 +26,7 @@ static FILE *file_in; static FILE *file_out; +static char *psn; #define MYNAME "CSV" @@ -48,6 +49,8 @@ static void wr_init(const char *fname, const char *args) { file_out = fopen(fname, "w"); + psn = get_option(args, "prefer_shortname"); + if (file_out == NULL) { fatal(MYNAME ": Cannot open %s for writing\n", fname); } @@ -143,8 +146,13 @@ csv_waypt_pr(const waypoint *wpt) lon = wpt->position.longitude.degrees; lat = wpt->position.latitude.degrees; - if (wpt->description) - description = csv_stringclean(wpt->description, ",\""); + if (psn) { + if (wpt->shortname) + description = csv_stringclean(wpt->shortname, ",\""); + } else { + if (wpt->description) + description = csv_stringclean(wpt->description, ",\""); + } if ((description == NULL) && wpt->notes) description = csv_stringclean(wpt->notes, ",\""); diff --git a/gpsbabel/waypt.c b/gpsbabel/waypt.c index 6aea8a528..761d17bd2 100644 --- a/gpsbabel/waypt.c +++ b/gpsbabel/waypt.c @@ -35,6 +35,11 @@ void waypt_add(waypoint *wpt) { ENQUEUE_TAIL(&waypt_head, &wpt->Q); + if (wpt->description == NULL) { + if (wpt->notes != NULL) { + wpt->description = xstrdup(wpt->notes); + } + } waypt_ct++; } -- 2.30.2